﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AlocaProfeV2.Modelos;
using AlocaProfeV2.Controller;
using System.Collections;
using System.Threading;

namespace AlocaProfeV2.View
{
    public partial class AssocDisciplina : System.Web.UI.Page
    {

        public static List<Disciplina> allDisciplinas = new List<Disciplina>();
        
        public DisciplinaController disciplinaController = new DisciplinaController();

        public ProfessorController professorController = new ProfessorController();

        protected void Page_Load(object sender, EventArgs e)
        {
            // carrega todas as disciplinas
            allDisciplinas = disciplinaController.listaDisciplina();
        }

        protected void dropSemestre_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.clearAll();

            // obtém as disciplinas daquele semestre 
            List<Disciplina> disciplinasSemestre = disciplinaController.listaDisciplinaPorSemestre(allDisciplinas, dropSemestre.SelectedIndex);
            
            // percorre as disciplinas do semestre e popula as tabelas matutino, vespertino e noturno
            foreach (Disciplina disciplina in disciplinasSemestre)
            {
                //renderiza as disciplinas de acordo com o período
                if(disciplina.Periodo.Equals(Periodo.Matutino.ToString())) 
                {
                    this.renderizaComponentesMatutino(disciplina);
                }
                else if (disciplina.Periodo.Equals(Periodo.Vespertino.ToString()))
                {
                    this.renderizaComponentesVespertino(disciplina);
                }
                else 
                {
                    this.renderizaComponentesNoturno(disciplina);
                }

            }

        }

        protected void saveButton_Click(object sender, EventArgs e)
        {
            // associa as disciplinas marcadas ao professor

            List<Int32> disciplinas = new List<Int32>();

            List<String> opcoes = new List<String>();

            // itera nos elementos marcados e adiciona a lista de disciplinas/opções
            foreach (Control control in this.listControlCollections())
            {
                if (control.GetType() == typeof(RadioButtonList))
                {
                    RadioButtonList element = (RadioButtonList) control;
                    if(element.SelectedValue != "") {
                        disciplinas.Add(Int32.Parse(element.Attributes["idDisciplina"]));
                        opcoes.Add(element.SelectedValue);
                    }
                }
                else
                {
                    CheckBox element = (CheckBox) control;
                    if (element.Checked)
                    {
                        disciplinas.Add(Int32.Parse(element.Attributes["idDisciplina"]));
                        opcoes.Add(element.Text);
                    }
                }
            }

            // instancia professor para alteração
            Professor professor = new Professor(Convert.ToInt32(Session["idUsu"]), disciplinas, opcoes);

            // atualiza as matérias daquele professor
            this.professorController.atualizaMaterias(professor);

            Page.ClientScript.RegisterStartupScript(this.GetType(), "ShowMessage", "alert('Associação realizada com sucesso!');", true);
        }

        //Obtém todas os controles checkbox e radiobuttonlist
        private List<Control> listControlCollections()
        {
            List<Control> controlList = new List<Control>();
            this.addControls(Page.Controls, controlList);

            return controlList;
        }

        //Obtém recursivamente os controls da página
        private void addControls(ControlCollection page, List<Control> controlList)
        {
            foreach (Control c in page)
            {
                if (c.ID != null && (c.GetType() == typeof(CheckBox) || c.GetType() == typeof(RadioButtonList)))
                {
                    controlList.Add(c);
                }

                if (c.HasControls())
                {
                    this.addControls(c.Controls, controlList);
                }
            }
        }

        private void renderizaComponentesMatutino(Disciplina disciplina)
        {
            String dia = disciplina.DiaSemana;

            switch (dia)
            {
                case "Segunda":
                    if (lblMatSegDisc.Text.Equals(""))
                    {
                        lblMatSegDisc.Text = disciplina.Sigla + "-" + disciplina.CodigoTurma;
                        checkMatSeg.Visible = disciplina.Alocada;
                        radioMatSeg.Visible = !disciplina.Alocada;
                        checkMatSeg.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                        radioMatSeg.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                    }
                    else
                    {
                        lblMatSegDiscTurma2.Text = disciplina.Sigla + "-" + disciplina.CodigoTurma;
                        lblMatSegDiscTurma2.Visible = true;
                        checkMatSegTurma2.Visible = disciplina.Alocada;
                        radioMatSegTurma2.Visible = !disciplina.Alocada;
                        checkMatSegTurma2.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                        radioMatSegTurma2.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                    }
                    break;
                case "Terça":
                    if (lblMatTerDisc.Text.Equals(""))
                    {
                        lblMatTerDisc.Text = disciplina.Sigla + "-" + disciplina.CodigoTurma;
                        checkMatTer.Visible = disciplina.Alocada;
                        radioMatTer.Visible = !disciplina.Alocada;
                        checkMatTer.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                        radioMatTer.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                    }
                    else
                    {
                        lblMatTerDiscTurma2.Text = disciplina.Sigla + "-" + disciplina.CodigoTurma;
                        lblMatTerDiscTurma2.Visible = true;
                        checkMatTerTurma2.Visible = disciplina.Alocada;
                        radioMatTerTurma2.Visible = !disciplina.Alocada;
                        checkMatTerTurma2.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                        radioMatTerTurma2.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                    }
                    break;
                case "Quarta":
                    if (lblMatQuaDisc.Text.Equals(""))
                    {
                        lblMatQuaDisc.Text = disciplina.Sigla + "-" + disciplina.CodigoTurma;
                        checkMatQua.Visible = disciplina.Alocada;
                        radioMatQua.Visible = !disciplina.Alocada;
                        checkMatQua.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                        radioMatQua.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                    }
                    else
                    {
                        lblMatQuaDiscTurma2.Text = disciplina.Sigla + "-" + disciplina.CodigoTurma;
                        lblMatQuaDiscTurma2.Visible = true;
                        checkMatQuaTurma2.Visible = disciplina.Alocada;
                        radioMatQuaTurma2.Visible = !disciplina.Alocada;
                        checkMatQuaTurma2.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                        radioMatQuaTurma2.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                    }
                    break;
                case "Quinta":
                    if (lblMatQuiDisc.Text.Equals(""))
                    {
                        lblMatQuiDisc.Text = disciplina.Sigla + "-" + disciplina.CodigoTurma;
                        checkMatQui.Visible = disciplina.Alocada;
                        radioMatQui.Visible = !disciplina.Alocada;
                        checkMatQui.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                        radioMatQui.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                    }
                    else
                    {
                        lblMatQuiDiscTurma2.Text = disciplina.Sigla + "-" + disciplina.CodigoTurma;
                        lblMatQuiDiscTurma2.Visible = true;
                        checkMatQuiTurma2.Visible = disciplina.Alocada;
                        radioMatQuiTurma2.Visible = !disciplina.Alocada;
                        checkMatQuiTurma2.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                        radioMatQuiTurma2.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                    }
                    break;
                case "Sexta":
                    if (lblMatSexDisc.Text.Equals(""))
                    {
                        lblMatSexDisc.Text = disciplina.Sigla + "-" + disciplina.CodigoTurma;
                        checkMatSex.Visible = disciplina.Alocada;
                        radioMatSex.Visible = !disciplina.Alocada;
                        checkMatSex.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                        radioMatSex.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                    }
                    else
                    {
                        lblMatSexDiscTurma2.Text = disciplina.Sigla + "-" + disciplina.CodigoTurma;
                        lblMatSexDiscTurma2.Visible = true;
                        checkMatSexTurma2.Visible = disciplina.Alocada;
                        radioMatSexTurma2.Visible = !disciplina.Alocada;
                        checkMatSexTurma2.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                        radioMatSexTurma2.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                    }
                    break;
                case "Sábado":
                    if (lblMatSexDisc.Text.Equals(""))
                    {
                        lblMatSabDisc.Text = disciplina.Sigla + "-" + disciplina.CodigoTurma;
                        checkMatSab.Visible = disciplina.Alocada;
                        radioMatSab.Visible = !disciplina.Alocada;
                        checkMatSab.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                        radioMatSab.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                    }
                    else
                    {
                        lblMatSabDiscTurma2.Text = disciplina.Sigla + "-" + disciplina.CodigoTurma;
                        lblMatSabDiscTurma2.Visible = true;
                        checkMatSabTurma2.Visible = disciplina.Alocada;
                        radioMatSabTurma2.Visible = !disciplina.Alocada;
                        checkMatSabTurma2.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                        radioMatSabTurma2.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                    }
                    break;
            }

        }

        private void renderizaComponentesVespertino(Disciplina disciplina)
        {
            String dia = disciplina.DiaSemana;

            switch (dia)
            {
                case "Segunda":
                    if (lblVesSegDisc.Text.Equals(""))
                    {
                        lblVesSegDisc.Text = disciplina.Sigla + "-" + disciplina.CodigoTurma;
                        checkVesSeg.Visible = disciplina.Alocada;
                        radioVesSeg.Visible = !disciplina.Alocada;
                        checkVesSeg.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                        radioVesSeg.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                    }
                    else
                    {
                        lblVesSegDiscTurma2.Text = disciplina.Sigla + "-" + disciplina.CodigoTurma;
                        lblVesSegDiscTurma2.Visible = true;
                        checkVesSegTurma2.Visible = disciplina.Alocada;
                        radioVesSegTurma2.Visible = !disciplina.Alocada;
                        checkVesSegTurma2.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                        radioVesSegTurma2.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                    }
                    break;
                case "Terça":
                    if (lblVesTerDisc.Text.Equals(""))
                    {
                        lblVesTerDisc.Text = disciplina.Sigla + "-" + disciplina.CodigoTurma;
                        checkVesTer.Visible = disciplina.Alocada;
                        radioVesTer.Visible = !disciplina.Alocada;
                        checkVesTer.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                        radioVesTer.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                    }
                    else
                    {
                        lblVesTerDiscTurma2.Text = disciplina.Sigla + "-" + disciplina.CodigoTurma;
                        lblVesTerDiscTurma2.Visible = true;
                        checkVesTerTurma2.Visible = disciplina.Alocada;
                        radioVesTerTurma2.Visible = !disciplina.Alocada;
                        checkVesTerTurma2.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                        radioVesTerTurma2.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                    }
                    break;
                case "Quarta":
                    if (lblVesQuaDisc.Text.Equals(""))
                    {
                        lblVesQuaDisc.Text = disciplina.Sigla + "-" + disciplina.CodigoTurma;
                        checkVesQua.Visible = disciplina.Alocada;
                        radioVesQua.Visible = !disciplina.Alocada;
                        checkVesQua.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                        radioVesQua.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                    }
                    else
                    {
                        lblVesQuaDiscTurma2.Text = disciplina.Sigla + "-" + disciplina.CodigoTurma;
                        lblVesQuaDiscTurma2.Visible = true;
                        checkVesQuaTurma2.Visible = disciplina.Alocada;
                        radioVesQuaTurma2.Visible = !disciplina.Alocada;
                        checkVesQuaTurma2.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                        radioVesQuaTurma2.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                    }
                    break;
                case "Quinta":
                    if (lblVesQuiDisc.Text.Equals(""))
                    {
                        lblVesQuiDisc.Text = disciplina.Sigla + "-" + disciplina.CodigoTurma;
                        checkVesQui.Visible = disciplina.Alocada;
                        radioVesQui.Visible = !disciplina.Alocada;
                        checkVesQui.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                        radioVesQui.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                    }
                    else
                    {
                        lblVesQuiDiscTurma2.Text = disciplina.Sigla + "-" + disciplina.CodigoTurma;
                        lblVesQuiDiscTurma2.Visible = true;
                        checkVesQuiTurma2.Visible = disciplina.Alocada;
                        radioVesQuiTurma2.Visible = !disciplina.Alocada;
                        checkVesQuiTurma2.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                        radioVesQuiTurma2.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                    }
                    break;
                case "Sexta":
                    if (lblVesSexDisc.Text.Equals(""))
                    {
                        lblVesSexDisc.Text = disciplina.Sigla + "-" + disciplina.CodigoTurma;
                        checkVesSex.Visible = disciplina.Alocada;
                        radioVesSex.Visible = !disciplina.Alocada;
                        checkVesSex.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                        radioVesSex.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                    }
                    else
                    {
                        lblVesSexDiscTurma2.Text = disciplina.Sigla + "-" + disciplina.CodigoTurma;
                        lblVesSexDiscTurma2.Visible = true;
                        checkVesSexTurma2.Visible = disciplina.Alocada;
                        radioVesSexTurma2.Visible = !disciplina.Alocada;
                        checkVesSexTurma2.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                        radioVesSexTurma2.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                    }
                    break;
                case "Sábado":
                    if (lblVesSexDisc.Text.Equals(""))
                    {
                        lblVesSabDisc.Text = disciplina.Sigla + "-" + disciplina.CodigoTurma;
                        checkVesSab.Visible = disciplina.Alocada;
                        radioVesSab.Visible = !disciplina.Alocada;
                        checkVesSab.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                        radioVesSab.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                    }
                    else
                    {
                        lblVesSabDiscTurma2.Text = disciplina.Sigla + "-" + disciplina.CodigoTurma;
                        lblVesSabDiscTurma2.Visible = true;
                        checkVesSabTurma2.Visible = disciplina.Alocada;
                        radioVesSabTurma2.Visible = !disciplina.Alocada;
                        checkVesSabTurma2.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                        radioVesSabTurma2.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                    }
                    break;
            }

        }

        private void renderizaComponentesNoturno(Disciplina disciplina)
        {
            String dia = disciplina.DiaSemana;

            switch (dia)
            {
                case "Segunda":
                    if (lblNotSegDisc.Text.Equals(""))
                    {
                        lblNotSegDisc.Text = disciplina.Sigla + "-" + disciplina.CodigoTurma;
                        checkNotSeg.Visible = disciplina.Alocada;
                        radioNotSeg.Visible = !disciplina.Alocada;
                        checkNotSeg.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                        radioNotSeg.Attributes.Add("idDisciplina", disciplina.Id.ToString());                        
                    }
                    else
                    {
                        lblNotSegDiscTurma2.Text = disciplina.Sigla + "-" + disciplina.CodigoTurma;
                        lblNotSegDiscTurma2.Visible = true;
                        checkNotSegTurma2.Visible = disciplina.Alocada;
                        radioNotSegTurma2.Visible = !disciplina.Alocada;
                        checkNotSegTurma2.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                        radioNotSegTurma2.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                    }
                    break;
                case "Terça":
                    if (lblNotTerDisc.Text.Equals(""))
                    {
                        lblNotTerDisc.Text = disciplina.Sigla + "-" + disciplina.CodigoTurma;
                        checkNotTer.Visible = disciplina.Alocada;
                        radioNotTer.Visible = !disciplina.Alocada;
                        checkNotTer.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                        radioNotTer.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                    }
                    else
                    {
                        lblNotTerDiscTurma2.Text = disciplina.Sigla + "-" + disciplina.CodigoTurma;
                        lblNotTerDiscTurma2.Visible = true;
                        checkNotTerTurma2.Visible = disciplina.Alocada;
                        radioNotTerTurma2.Visible = !disciplina.Alocada;
                        checkNotTerTurma2.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                        radioNotTerTurma2.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                    }
                    break;
                case "Quarta":
                    if (lblNotQuaDisc.Text.Equals(""))
                    {
                        lblNotQuaDisc.Text = disciplina.Sigla + "-" + disciplina.CodigoTurma;
                        checkNotQua.Visible = disciplina.Alocada;
                        radioNotQua.Visible = !disciplina.Alocada;
                        checkNotQua.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                        radioNotQua.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                    }
                    else
                    {
                        lblNotQuaDiscTurma2.Text = disciplina.Sigla + "-" + disciplina.CodigoTurma;
                        lblNotQuaDiscTurma2.Visible = true;
                        checkNotQuaTurma2.Visible = disciplina.Alocada;
                        radioNotQuaTurma2.Visible = !disciplina.Alocada;
                        checkNotQuaTurma2.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                        radioNotQuaTurma2.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                    }
                    break;
                case "Quinta":
                    if (lblNotQuiDisc.Text.Equals(""))
                    {
                        lblNotQuiDisc.Text = disciplina.Sigla + "-" + disciplina.CodigoTurma;
                        checkNotQui.Visible = disciplina.Alocada;
                        radioNotQui.Visible = !disciplina.Alocada;
                        checkNotQui.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                        radioNotQui.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                    }
                    else
                    {
                        lblNotQuiDiscTurma2.Text = disciplina.Sigla + "-" + disciplina.CodigoTurma;
                        lblNotQuiDiscTurma2.Visible = true;
                        checkNotQuiTurma2.Visible = disciplina.Alocada;
                        radioNotQuiTurma2.Visible = !disciplina.Alocada;
                        checkNotQuiTurma2.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                        radioNotQuiTurma2.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                    }
                    break;
                case "Sexta":
                    if (lblNotSexDisc.Text.Equals(""))
                    {
                        lblNotSexDisc.Text = disciplina.Sigla + "-" + disciplina.CodigoTurma;
                        checkNotSex.Visible = disciplina.Alocada;
                        radioNotSex.Visible = !disciplina.Alocada;
                        checkNotSex.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                        radioNotSex.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                    }
                    else
                    {
                        lblNotSexDiscTurma2.Text = disciplina.Sigla + "-" + disciplina.CodigoTurma;
                        lblNotSexDiscTurma2.Visible = true;
                        checkNotSexTurma2.Visible = disciplina.Alocada;
                        radioNotSexTurma2.Visible = !disciplina.Alocada;
                        checkNotSexTurma2.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                        radioNotSexTurma2.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                    }
                    break;
                case "Sábado":
                    if (lblNotSexDisc.Text.Equals(""))
                    {
                        lblNotSabDisc.Text = disciplina.Sigla + "-" + disciplina.CodigoTurma;
                        checkNotSab.Visible = disciplina.Alocada;
                        radioNotSab.Visible = !disciplina.Alocada;
                        checkNotSab.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                        radioNotSab.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                    }
                    else
                    {
                        lblNotSabDiscTurma2.Text = disciplina.Sigla + "-" + disciplina.CodigoTurma;
                        lblNotSabDiscTurma2.Visible = true;
                        checkNotSabTurma2.Visible = disciplina.Alocada;
                        radioNotSabTurma2.Visible = !disciplina.Alocada;
                        checkNotSabTurma2.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                        radioNotSabTurma2.Attributes.Add("idDisciplina", disciplina.Id.ToString());
                    }
                    break;
            }

        }

        private void clearAll()
        {
            //MATUTINO
            this.clearMatutinoFields();

            //VESPERTINO
            this.clearVespertinoFields();

            //NOTURNO
            this.clearNoturnoFields();
        }

        private void clearMatutinoFields()
        {
            lblMatSegDisc.Text = "";
            lblMatTerDisc.Text = "";
            lblMatQuaDisc.Text = "";
            lblMatQuiDisc.Text = "";
            lblMatSexDisc.Text = "";
            lblMatSabDisc.Text = "";

            lblMatSegDiscTurma2.Text = "";
            lblMatTerDiscTurma2.Text = "";
            lblMatQuaDiscTurma2.Text = "";
            lblMatQuiDiscTurma2.Text = "";
            lblMatSexDiscTurma2.Text = "";
            lblMatSabDiscTurma2.Text = "";
            lblMatSegDiscTurma2.Visible = false;
            lblMatTerDiscTurma2.Visible = false;
            lblMatQuaDiscTurma2.Visible = false;
            lblMatQuiDiscTurma2.Visible = false;
            lblMatSexDiscTurma2.Visible = false;
            lblMatSabDiscTurma2.Visible = false;

            radioMatSeg.Visible = false;
            radioMatTer.Visible = false;
            radioMatQua.Visible = false;
            radioMatQui.Visible = false;
            radioMatSex.Visible = false;
            radioMatSab.Visible = false;

            radioMatSegTurma2.Visible = false;
            radioMatTerTurma2.Visible = false;
            radioMatQuaTurma2.Visible = false;
            radioMatQuiTurma2.Visible = false;
            radioMatSexTurma2.Visible = false;
            radioMatSabTurma2.Visible = false;

            checkMatSeg.Visible = false;
            checkMatTer.Visible = false;
            checkMatQua.Visible = false;
            checkMatQui.Visible = false;
            checkMatSex.Visible = false;
            checkMatSab.Visible = false;

            checkMatSegTurma2.Visible = false;
            checkMatTerTurma2.Visible = false;
            checkMatQuaTurma2.Visible = false;
            checkMatQuiTurma2.Visible = false;
            checkMatSexTurma2.Visible = false;
            checkMatSabTurma2.Visible = false;
        }

        private void clearVespertinoFields()
        {
            lblVesSegDisc.Text = "";
            lblVesTerDisc.Text = "";
            lblVesQuaDisc.Text = "";
            lblVesQuiDisc.Text = "";
            lblVesSexDisc.Text = "";
            lblVesSabDisc.Text = "";

            lblVesSegDiscTurma2.Text = "";
            lblVesTerDiscTurma2.Text = "";
            lblVesQuaDiscTurma2.Text = "";
            lblVesQuiDiscTurma2.Text = "";
            lblVesSexDiscTurma2.Text = "";
            lblVesSabDiscTurma2.Text = "";
            lblVesSegDiscTurma2.Visible = false;
            lblVesTerDiscTurma2.Visible = false;
            lblVesQuaDiscTurma2.Visible = false;
            lblVesQuiDiscTurma2.Visible = false;
            lblVesSexDiscTurma2.Visible = false;
            lblVesSabDiscTurma2.Visible = false;

            radioVesSeg.Visible = false;
            radioVesTer.Visible = false;
            radioVesQua.Visible = false;
            radioVesQui.Visible = false;
            radioVesSex.Visible = false;
            radioVesSab.Visible = false;

            radioVesSegTurma2.Visible = false;
            radioVesTerTurma2.Visible = false;
            radioVesQuaTurma2.Visible = false;
            radioVesQuiTurma2.Visible = false;
            radioVesSexTurma2.Visible = false;
            radioVesSabTurma2.Visible = false;

            checkVesSeg.Visible = false;
            checkVesTer.Visible = false;
            checkVesQua.Visible = false;
            checkVesQui.Visible = false;
            checkVesSex.Visible = false;
            checkVesSab.Visible = false;

            checkVesSegTurma2.Visible = false;
            checkVesTerTurma2.Visible = false;
            checkVesQuaTurma2.Visible = false;
            checkVesQuiTurma2.Visible = false;
            checkVesSexTurma2.Visible = false;
            checkVesSabTurma2.Visible = false;
        }

        private void clearNoturnoFields()
        {
            lblNotSegDisc.Text = "";
            lblNotTerDisc.Text = "";
            lblNotQuaDisc.Text = "";
            lblNotQuiDisc.Text = "";
            lblNotSexDisc.Text = "";
            lblNotSabDisc.Text = "";

            lblNotSegDiscTurma2.Text = "";
            lblNotTerDiscTurma2.Text = "";
            lblNotQuaDiscTurma2.Text = "";
            lblNotQuiDiscTurma2.Text = "";
            lblNotSexDiscTurma2.Text = "";
            lblNotSabDiscTurma2.Text = "";
            lblNotSegDiscTurma2.Visible = false;
            lblNotTerDiscTurma2.Visible = false;
            lblNotQuaDiscTurma2.Visible = false;
            lblNotQuiDiscTurma2.Visible = false;
            lblNotSexDiscTurma2.Visible = false;
            lblNotSabDiscTurma2.Visible = false;

            radioNotSeg.Visible = false;
            radioNotTer.Visible = false;
            radioNotQua.Visible = false;
            radioNotQui.Visible = false;
            radioNotSex.Visible = false;
            radioNotSab.Visible = false;

            radioNotSegTurma2.Visible = false;
            radioNotTerTurma2.Visible = false;
            radioNotQuaTurma2.Visible = false;
            radioNotQuiTurma2.Visible = false;
            radioNotSexTurma2.Visible = false;
            radioNotSabTurma2.Visible = false;

            checkNotSeg.Visible = false;
            checkNotTer.Visible = false;
            checkNotQua.Visible = false;
            checkNotQui.Visible = false;
            checkNotSex.Visible = false;
            checkNotSab.Visible = false;

            checkNotSegTurma2.Visible = false;
            checkNotTerTurma2.Visible = false;
            checkNotQuaTurma2.Visible = false;
            checkNotQuiTurma2.Visible = false;
            checkNotSexTurma2.Visible = false;
            checkNotSabTurma2.Visible = false;
        }

    }
}